package com.sunforum.forum.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sunforum.common.annotation.Log;
import com.sunforum.common.core.controller.BaseController;
import com.sunforum.common.core.domain.AjaxResult;
import com.sunforum.common.enums.BusinessType;
import com.sunforum.forum.domain.PcColumnClassification;
import com.sunforum.forum.service.IPcColumnClassificationService;
import com.sunforum.common.utils.poi.ExcelUtil;

/**
 * pc_栏目分类Controller
 * 
 * @author sunforum
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/forum/classification")
public class PcColumnClassificationController extends BaseController
{
    @Autowired
    private IPcColumnClassificationService pcColumnClassificationService;

    /**
     * 查询pc_栏目分类列表
     */
    @PreAuthorize("@ss.hasPermi('forum:classification:list')")
    @GetMapping("/list")
    public AjaxResult list(PcColumnClassification pcColumnClassification)
    {
        List<PcColumnClassification> list = pcColumnClassificationService.selectPcColumnClassificationList(pcColumnClassification);
        return success(list);
    }

    /**
     * 导出pc_栏目分类列表
     */
    @PreAuthorize("@ss.hasPermi('forum:classification:export')")
    @Log(title = "pc_栏目分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PcColumnClassification pcColumnClassification)
    {
        List<PcColumnClassification> list = pcColumnClassificationService.selectPcColumnClassificationList(pcColumnClassification);
        ExcelUtil<PcColumnClassification> util = new ExcelUtil<PcColumnClassification>(PcColumnClassification.class);
        util.exportExcel(response, list, "pc_栏目分类数据");
    }

    /**
     * 获取pc_栏目分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('forum:classification:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pcColumnClassificationService.selectPcColumnClassificationById(id));
    }

    /**
     * 新增pc_栏目分类
     */
    @PreAuthorize("@ss.hasPermi('forum:classification:add')")
    @Log(title = "pc_栏目分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PcColumnClassification pcColumnClassification)
    {
        return toAjax(pcColumnClassificationService.insertPcColumnClassification(pcColumnClassification));
    }

    /**
     * 修改pc_栏目分类
     */
    @PreAuthorize("@ss.hasPermi('forum:classification:edit')")
    @Log(title = "pc_栏目分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PcColumnClassification pcColumnClassification)
    {
        return toAjax(pcColumnClassificationService.updatePcColumnClassification(pcColumnClassification));
    }

    /**
     * 删除pc_栏目分类
     */
    @PreAuthorize("@ss.hasPermi('forum:classification:remove')")
    @Log(title = "pc_栏目分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pcColumnClassificationService.deletePcColumnClassificationByIds(ids));
    }
}
